package com.example.service.impl;

import com.example.model.entity.StudentEntity;
import com.example.repository.StudentRepository;
import com.example.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
@Slf4j
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentRepository studentRepository;

    @Override
    public Flux<StudentEntity> findAll() {
        return studentRepository.findAll();
    }

    @Override
    public Mono<StudentEntity> update(Long id) {
        StudentEntity studentEntity = new StudentEntity();
        studentEntity.setId(id);
        studentEntity.setCode("aaaa");
        studentEntity.setName("albert");
        Mono<StudentEntity> studentEntityMono = studentRepository.save(studentEntity);
        for (int i = 1; i < 1000; i++) {
            log.info("service todo other things..." + i);
        }
        return studentEntityMono;
    }


}
